home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / 3d_hyper / 3d_hyper.dcr / Scripts_47_Camera Stuff.ls < prev    next >
Encoding:
Text File  |  2011-06-09  |  1.1 KB  |  36 lines

  1. global gCamera, gCar, gRacers
  2.  
  3. on updateCamera
  4.   carPos = gCar.worldPosition
  5.   targetPos = gRacers[1].pTrackBelowPos.isectPosition
  6.   TurnData = gRacers[1].pTurnData
  7.   tempTrans = transform()
  8.   tempTrans.position = targetPos + vector(0, 5, 0)
  9.   tempTrans.rotation = vector(0, TurnData.currentTurn, 0)
  10.   if gRacers[1].pAmBoosting then
  11.     currTime = the milliSeconds
  12.     timePassed = the milliSeconds - gRacers[1].pTimeBoosting
  13.     if timePassed < 1000 then
  14.       percentTime = timePassed / 3500.0
  15.     else
  16.       if timePassed < 3000 then
  17.         percentTime = 0.5
  18.       else
  19.         percentTime = 0.5 + ((timePassed - 3000) / 1750.0)
  20.       end if
  21.     end if
  22.     cameraOffset = 20 * sin(percentTime * PI)
  23.     tempTrans.preTranslate(vector(0, 15, 55 + cameraOffset))
  24.     gCamera.transform.interpolateTo(tempTrans, 100)
  25.   else
  26.     tempTrans.preTranslate(vector(0, 15, 55))
  27.     gCamera.transform.interpolateTo(tempTrans, 100)
  28.   end if
  29.   gCamera.transform.interpolateTo(tempTrans, 100)
  30.   if (gCar.worldPosition.y - (targetPos.y + 12)) > 0 then
  31.     gCamera.pointAt(gCar.worldPosition)
  32.   else
  33.     gCamera.pointAt(targetPos + vector(0, 12, 0))
  34.   end if
  35. end
  36.